<template>
    <div>

    </div>
</template>
<script>
function recursion(newobj, oldobj) {
    for (let k in oldobj) {
        if (Object.prototype.toString.call(oldobj[k]) === "[object Array]") {
            newobj[k] = [];
            recursion(newobj[k], oldobj[k]);
        } else if (Object.prototype.toString.call(oldobj[k]) === "[object Object]") {
            newobj[k] = {};
            recursion(newobj[k], oldobj[k]);
        } else {
            newobj[k] = oldobj[k];
        }
    }
}

let obj = {
    name: "zhangsan",
    child: {
        age: 10,
        arr: ["toy"]
    }
};

let obj5 = {};
recursion(obj5, obj);
obj5.name = "lisi";
obj5.child.arr[0] = "芭比娃娃";

console.log(obj, "obj");
console.log(obj5, "obj5");
</script>